package com.wealth.scsj.b_app.view.fragment.fourmodel;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.wealth.scsj.b_app.R;
import com.wealth.scsj.b_app.base.GetOrderIncomeAndOrderQuantityBase;
import com.wealth.scsj.b_app.bean.StoreOperationMainBean;
import com.wealth.scsj.b_app.presenter.GetOrderIncomeAndOrderQuantityPresenter;
import com.wealth.scsj.b_app.presenter.UpdateUserProfilePicturePresenter;
import com.wealth.scsj.b_app.utils.SkipUtils;
import com.wealth.scsj.b_app.view.fragment.basemodel.BaseFragment;

import okhttp3.RequestBody;


/**
 * 门店运营
 */
public class ShopFragment extends BaseFragment implements View.OnClickListener,GetOrderIncomeAndOrderQuantityBase.IView {

    private View view;
    private TextView mTvTopTittle;
    private TextView mOrderIncomeTv;
    private TextView mOrderNumTv;
    private LinearLayout mProductManageLl;
    private LinearLayout mEvaluateManageLl;

    GetOrderIncomeAndOrderQuantityPresenter mPresenter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.fragment_shop, null);
        initView(inflate, null);
        mPresenter =new GetOrderIncomeAndOrderQuantityPresenter(this);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("id", "dianpu1");
        RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), jsonObject.toString());
        mPresenter.deliverData(body);
        initListener();
        initData();
        return inflate;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {

        mTvTopTittle =  view.findViewById(R.id.tv_top_tittle);
        mOrderIncomeTv = view.findViewById(R.id.order_income_tv);
        mOrderNumTv = view.findViewById(R.id.order_num_tv);
        mProductManageLl =  view.findViewById(R.id.product_manage_ll);
        mEvaluateManageLl =  view.findViewById(R.id.evaluate_manage_ll);

    }

    @Override
    protected void initListener() {
        mProductManageLl.setOnClickListener(this);
        mEvaluateManageLl.setOnClickListener(this);
    }

    @Override
    protected void initData() {
        mTvTopTittle.setText("门店运营");
    }

    @Override
    protected int getLayoutId() {
        return 0;
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.product_manage_ll:
                SkipUtils.toGoodsManagePage(getHoldingActivity());
                break;
            case R.id.evaluate_manage_ll:
                SkipUtils.toEvaluateManagePage(getHoldingActivity());
                break;
        }
    }

    /**
     * 接口回调
     * @param s
     * @param bean
     */
    @Override
    public void showSuccessMsg(String s, StoreOperationMainBean bean) {
        if(bean.isSuccess()){
            mOrderIncomeTv.setText(bean.getData().getOrderIncomeDay());
            mOrderNumTv.setText(bean.getData().getOrderQuantityDay());
        }
    }

    @Override
    public void showErrorMsg(String s) {

    }
}
